package com.qk.controller;

import com.qk.common.PageResult;
import com.qk.common.Result;
import com.qk.entity.OperateLog;
import com.qk.service.OperateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 操作日志管理控制器
 */
@Slf4j
@RestController
@RequestMapping("/logs")
public class OperateLogController {

    @Autowired
    private OperateLogService operateLogService;

    /**
     * 分页查询操作日志列表
     */
    @GetMapping
    public Result getLogs(String operateUserName, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize) {
        log.info("分页查询操作日志列表, operateUserName: {}, page: {}, pageSize: {}", operateUserName, page, pageSize);
        PageResult<OperateLog> logPage = operateLogService.getLogsByCondition(operateUserName, page, pageSize);
        return Result.success(logPage);
    }
}